﻿@model  IList<DiscountRequirement> 
@{
    var dic = ViewBag.RequirementRule as IDictionary<byte, string>;
}
<script type="text/javascript">
function ruleChanged(obj) {
    var val = $(obj).val();
    var html = '<input type="text" />';
    switch (val) {
        case '1':html = '<input type="text" name="SpentAmount" class="required" />'; break;
    }
    console.log(html);
    $("#ruleval").html(html);
}
</script>
<div class="pageHeader">
    <form method="post" action="/Promotion/CreateRequirement/@ViewBag.DiscountId" class="pageForm required-validate" onsubmit="return validateCallback(this, ajaxRefreshDialog);">
    <div class="searchBar">
        <ul class="searchContent">
            <li>
                <label>
                    规 则：</label>
                <select name="RequirementRule" style="width: 120px;" onchange="ruleChanged(this);">
                    @if (dic != null)
                    {
                        foreach (var o in dic)
                        {
                        <option value="@o.Key">@o.Value</option>
                        }
                    }
                    else
                    {
                        <option value="0">请选择规则</option>                    
                    }
                </select>
            </li>
            <li>
                <label>
                    值：</label><div id="ruleval"></div></li>
        </ul>
        <div class="subBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit">
                                提 交</button></div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    </form>
</div>
<div class="pageContent">
    <table class="table" width="100%">
        <thead>
            <tr>
                <th width="50">
                    Id
                </th>
                <th>
                    规 则
                </th>
            </tr>
        </thead>
        <tbody>
            @for (var i = 0; i < Model.Count; i++)
            {
                var o = Model[i];
                <tr>
                    <td>@(i + 1)
                    </td>
                    <td>@o.GetRequirementRule()
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>
